import smtplib
from email.mime.text import MIMEText
from email.header import Header
from email.utils import parseaddr, formataddr

PeopleWhoCopied = ['baimianxiao1@qq.com', '2516991466@qq.com']
mail_host = "smtp.qq.com"  # 设置服务器，163的话直接把QQ替换成163就好了，端口是25
mail_user = "2873678416@qq.com"  # 用户名
mail_pass = "eoyimmnszkcmdgje"  # 口令，需要去qq邮箱设置里面生成动态授权码
# 注意这里不是qq邮箱的密码，输入密码是连接不上滴
sender = '2873678416@qq.com'   # 发件人
receivers = ['2873678416@qq.com']  # 接收邮件，可设置为你的QQ邮箱或者其他邮箱
subject = '标题'
email_body = 'QAQ'
message = MIMEText(email_body, 'plain', 'utf-8')
message['Subject'] = Header(subject, 'utf-8')
message["From"] = formataddr(parseaddr("云青<2873678416@qq.com>"))
message["To"] = "云青"
message["Cc"] = 'baimianxiao1@qq.com'
try:
    smtpObj = smtplib.SMTP_SSL(host=mail_host, port=465)  # 采用加密协议的smtp服务器
    smtpObj.login(mail_user, mail_pass)
    smtpObj.sendmail(sender, receivers+PeopleWhoCopied, message.as_string())
    print("邮件发送成功")
except smtplib.SMTPException:
    print("Error: 无法发送邮件")

